<?php
$tab=(int)$_GET['tab'];
$time=time();
//$check = checkRed($options['teacher'],$openid);
$t = checkTeacher($openid);
?>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>教师首页</title>
<link rel="stylesheet" href="/skin/weui/weui.min.css"/>
<style>
body { background-color: #f8f8f8; }
.container, .page { position: absolute; top: 0; right: 0; bottom: 0; left: 0 }
.page__hd { padding: 30px; }
.page__title { text-align:center; font-size: 24px; font-weight: 400; color:#4ABB44; }
.page__desc { margin-top: 5px; color: #888; text-align: center; font-size: 14px; }
.weui-footer { margin-bottom: 40px; margin-top: 20px; }

.selectTime .weui-cell__ft{ font-size:16px;}
.weui-prompt-input{padding: 14px 6px;border: 1px solid #ccc;box-sizing: border-box;height: 2em;width: 80%;margin-top: 10px;}
.uidActionSheet .weui-actionsheet__menu .weui-actionsheet__cell{ padding:5px 0;}
/* Flow 流程 */
.weui-wepay-flow,.weui-wepay-flow-auto{padding:40px}
.weui-wepay-flow__bd{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center}
.weui-wepay-flow__li{position:relative;z-index:1;width:14px;height:14px}
.weui-wepay-flow__li .weui-wepay-flow__state{position:absolute;top:0;left:0;box-sizing:border-box;width:14px;height:14px;border-radius:7px;color:#fff;text-align:center;font-size:10px;line-height:14px}
.weui-wepay-flow__state{background-color:#e2e2e2}
.weui-wepay-flow__li_done .weui-wepay-flow__state{background-color:#09bb07}
[class*=" weui-wepay-flow__title-"],[class^=weui-wepay-flow__title-]{position:absolute;color:#999;text-align:center;white-space:nowrap;font-weight:400;font-size:14px}
.weui-wepay-flow__title-top{bottom:20px;left:50%;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__li_done .weui-wepay-flow__title-top{color:#333}
.weui-wepay-flow__title-bottom{top:20px;left:50%;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__li_done .weui-wepay-flow__title-bottom{color:#333}
.weui-wepay-flow__title-left{top:50%;right:30px;text-align:right;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__li_done .weui-wepay-flow__title-left{color:#333}
.weui-wepay-flow__title-right{top:50%;left:30px;text-align:left;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__li_done .weui-wepay-flow__title-right{color:#333}
[class*=" weui-wepay-flow__intro-"],[class^=weui-wepay-flow__intro-]{position:relative;padding:0 6px;height:20px;border-radius:4px;background-color:#ff8a00;color:#fff;white-space:nowrap;font-size:10px;line-height:20px}
[class*=" weui-wepay-flow__intro-"]:after,[class^=weui-wepay-flow__intro-]:after{position:absolute;display:inline-block;overflow:hidden;width:0;height:0;content:'';font-size:0}
.weui-wepay-flow__intro-top{position:absolute;bottom:25px}
.weui-wepay-flow__intro-top,.weui-wepay-flow__intro-top:after{left:50%;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__intro-top:after{bottom:-10px;border-color:#ff8a00 transparent transparent;border-style:solid;border-width:5px 3px}
.weui-wepay-flow__intro-bottom{position:absolute;top:25px}
.weui-wepay-flow__intro-bottom,.weui-wepay-flow__intro-bottom:after{left:50%;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__intro-bottom:after{top:-10px;border-color:transparent transparent #ff8a00;border-style:dashed dashed solid;border-width:5px 3px}
.weui-wepay-flow__intro-right{position:absolute;left:36px}
.weui-wepay-flow-auto__li .font{font-size:14px;}
.weui-wepay-flow__intro-right,.weui-wepay-flow__intro-right:after{top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__intro-right:after{left:-10px;border-color:transparent #ff8a00 transparent transparent;border-style:solid;border-width:3px 5px}
.weui-wepay-flow__intro-left{position:absolute;right:36px}
.weui-wepay-flow__intro-left,.weui-wepay-flow__intro-left:after{top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__intro-left:after{right:-10px;border-color:transparent transparent transparent #ff8a00;border-style:solid;border-width:3px 5px}
[class^=weui-wepay-flow__info-]{position:relative;position:absolute;padding:0 6px;height:14px;border-radius:2px;background-color:#09bb07;color:#fff;white-space:nowrap;font-size:10px;line-height:14px}
[class^=weui-wepay-flow__info-]:after{position:absolute;display:inline-block;overflow:hidden;width:0;height:0;content:'';font-size:0}
.weui-wepay-flow__line_ing [class^=weui-wepay-flow__info-]{display:block}
.weui-wepay-flow__info-top{bottom:11px;left:50%;display:none;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__line_ing .weui-wepay-flow__info-top{display:block}
.weui-wepay-flow__info-top:after{bottom:-10px;border-color:#09bb07 transparent transparent;border-style:solid;border-width:5px 3px}
.weui-wepay-flow__info-bottom,.weui-wepay-flow__info-top:after{left:50%;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__info-bottom{top:11px;display:none}
.weui-wepay-flow__line_ing .weui-wepay-flow__info-bottom{display:block}
.weui-wepay-flow__info-bottom:after{top:-10px;left:50%;border-color:transparent transparent #09bb07;border-style:dashed dashed solid;border-width:5px 3px;-webkit-transform:translate(-50%);transform:translate(-50%)}
.weui-wepay-flow__info-left{top:50%;right:9pt;display:none;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__line_ing .weui-wepay-flow__info-left{display:block}
.weui-wepay-flow__info-left:after{right:-10px;border-color:transparent transparent transparent #09bb07;border-style:solid;border-width:3px 5px}
.weui-wepay-flow__info-left:after,.weui-wepay-flow__info-right{top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__info-right{left:9pt;display:none}
.weui-wepay-flow__line_ing .weui-wepay-flow__info-right{display:block}
.weui-wepay-flow__info-right:after{top:50%;left:-10px;border-color:transparent #09bb07 transparent transparent;border-style:solid;border-width:3px 5px;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
.weui-wepay-flow__line{position:relative;height:3px;background-color:#e2e2e2;-webkit-box-flex:1;-ms-flex:1;flex:1}
.weui-wepay-flow__title{color:#999;font-weight:400;font-size:14px}
.weui-wepay-flow__info{color:#999;font-size:9pt}
.weui-wepay-flow__process{position:relative;display:none;height:3px;background-color:#09bb07}
.weui-wepay-flow__line_ing .weui-wepay-flow__process{display:block;width:50%}
.weui-wepay-flow__line_done .weui-wepay-flow__process{display:block}
.weui-wepay-flow_custom .weui-wepay-flow__bd{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}
.weui-wepay-flow_custom .weui-wepay-flow__line{width:75pt;-webkit-box-flex:0;-ms-flex:none;flex:none}
.weui-wepay-flow_vertical .weui-wepay-flow__bd{box-sizing:border-box;height:100%;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}
.weui-wepay-flow_vertical .weui-wepay-flow__line{width:3px;height:auto}
.weui-wepay-flow_vertical .weui-wepay-flow__line_ing .weui-wepay-flow__process{height:50%}
.weui-wepay-flow_vertical .weui-wepay-flow__process{position:absolute;top:0;left:0;width:3px;height:100%}
.weui-wepay-flow_vertical .weui-wepay-flow__line_done .weui-wepay-flow__process{height:100%}
.weui-wepay-flow_vertical-custom .weui-wepay-flow__bd{box-sizing:border-box;height:100%;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}
.weui-wepay-flow_vertical-custom .weui-wepay-flow__line{width:3px;-webkit-box-flex:0;-ms-flex:none;flex:none}
.weui-wepay-flow_vertical-custom .weui-wepay-flow__line_ing .weui-wepay-flow__process{height:50%}
.weui-wepay-flow_vertical-custom .weui-wepay-flow__process{position:absolute;top:0;left:0;width:3px;height:100%}
.weui-wepay-flow_vertical-custom .weui-wepay-flow__line_done .weui-wepay-flow__process{height:100%}
.weui-wepay-flow-auto,.weui-wepay-flow-auto__bd{position:relative}
.weui-wepay-flow-auto__state{position:absolute;top:4px;left:0;z-index:2;width:14px;height:14px;border-radius:7px;background-color:#e2e2e2;color:#fff;text-align:center;font-size:10px;line-height:14px}
.weui-wepay-flow-auto__state_on{background-color:#09bb07}
.weui-wepay-flow-auto__line{position:absolute;top:10px;bottom:-4px;left:6px;z-index:1;width:2px;background-color:#ddd}
.weui-wepay-flow-auto__line_on{background-color:#09bb07}
.weui-wepay-flow-auto__li{position:relative;padding-bottom:20px;padding-left:30px}
.weui-wepay-flow-auto__title{color:#999;font-weight:400;font-size:14px}
.weui-wepay-flow-auto__info{color:#999;font-size:9pt}
</style>
</head>
<body>
<div class="page">
	<div class="page__bd" style="height: 100%;">
		<div class="weui-tab" id="tab">
			<div class="weui-tab__panel">
				<div class="weui-tab__content">
					<div id="qianDaoForm" style="display:none;">
						<div class="weui-cells weui-cells_form">
							<div class="weui-cell weui-cell_select weui-cell_select-after">
								<div class="weui-cell__hd">
									<label for="" class="weui-label">上课情况</label>
								</div>
								<div class="weui-cell__bd">
									<select class="weui-select" name="star" id="star">
										<option value="1">一星</option>
										<option value="2">二星</option>
										<option value="3">三星</option>
										<option value="4">四星</option>
										<option value="5">五星</option>
									</select>
								</div>
							</div>
							<div class="weui-cell">
								<div class="weui-cell__hd"><label for="" class="weui-label">备注说明</label></div>
								<div class="weui-cell__bd">
									<input class="weui-input" value="" placeholder="请输入孩子上课备注说明" id="QDBZ" type="text">
								</div>
							</div>
						</div>
						<div class="weui-cells weui-cells_form">
							<div class="weui-cell">
								<div class="weui-cell__hd"><label for="" class="weui-label">时间</label></div>
								<div class="weui-cell__bd">
									<input class="weui-input" value="<?=date("Y-m-d H:i")?>" type="text" disabled>
								</div>
							</div>
							<div class="weui-cell">
								<div class="weui-cell__hd"><label for="" class="weui-label">学生</label></div>
								<div class="weui-cell__bd">
									<input class="weui-input" value="" name="" type="text" disabled>
								</div>
							</div>
							<div class="weui-cell">
								<div class="weui-cell__hd"><label for="" class="weui-label">老师</label></div>
								<div class="weui-cell__bd">
									<input class="weui-input" value="<?=$t['tidName']?>" type="text" disabled>
								</div>
							</div>
							<!-- div class="weui-cell">
								<div class="weui-cell__hd"><label for="" class="weui-label">时间</label></div>
								<div class="weui-cell__bd">
									<input class="weui-input" value="<?=date("Y-m-dTH:i:s.510")?>" placeholder="" type="datetime-local">
								</div>
							</div -->
						</div>
						<div class="weui-btn-area">
							<a class="weui-btn weui-btn_primary" href="javascript:" id="addQianDao">确定</a>
							<a class="weui-btn weui-btn_default" href="javascript:" id="escQianDao">返回</a>
						</div>
					</div>
					<div id="uidList">
						<div class="page__hd">
							<h1 class="page__title">学生管理</h1>
							<p class="page__desc">欢迎你 <?=$t['tidName']?></p>
						</div>
						<div class="weui-cells">
							<?php
							$bqno=0;
							$sql=$empire->query(whereSQL($options['student'],0,'id,title,newstime,uidName,QRurl,QRkey,week1,week2,time1,time2')."tid='$t[id]' and hide=0 order by id DESC limit 200");
							while($r=$empire->fetch($sql))        //循环获取查询记录
							{
								++$bqno;
								$QRurl='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=';
								if($r['QRkey'])
								{
									$QRurl .= urlencode($r['QRkey']);
								}
								else
								{
									$QRurl .= urlencode(getStudentQR($r['id']));
								}
								
								$shangKeNum = shangKeNum(0,$r['id']);
								$chongZhiNum = chongZhiNum(0,$r['id']);
								?>
							<a class="weui-cell weui-cell_access uidInfor" id="uidInfor_<?=$r['id']?>" uid="<?=$r['id']?>" uidName="<?=$r['uidName']?>" week1="<?=$r['week1']?>" week2="<?=$r['week2']?>" time1="<?=$r['time1']?>" time2="<?=$r['time2']?>" uidQRUrl="<?=$QRurl?>" href="javascript:;">
								<div class="weui-cell__hd" style="width:100px;">
									<p><?=$bqno?>. <?=$r['uidName']?></p>
								</div>
								<div class="weui-cell__bd">
									<?php
									if($r['week2'])
									{
									?>
									<p style="font-size:9px;">周<?=week($r['week1'])?> <?=$r['time1']?><br />周<?=week($r['week2'])?> <?=$r['time2']?></p>
									<?php
									}
									else
									{
									?>
									<p style="font-size:9px;">周<?=week($r['week1'])?> <?=$r['time1']?></p>
									<?php
									}
									?>
									
								</div>
								<div class="weui-cell__ft">剩余<?=$chongZhiNum-$shangKeNum?>节</div>
							</a>
								<?php
							}
							?>
						</div>
					</div>
					<div id="uidLog" style="display:none; background-color:#FFF;"">
						<!-- div class="page__hd">
							<h1 class="page__title">学生姓名</h1>
							<p class="page__desc"></p>
						</div>
						<div class="weui-wepay-flow-auto">
							<a href="javascript:;" class="weui-btn weui-btn_primary" id="uidLogClose">返回</a>
							<div class="weui-wepay-flow-auto__bd">
								<div class="weui-wepay-flow-auto__li" style="height:30px;">
									<div class="weui-wepay-flow-auto__state weui-wepay-flow-auto__state_on"></div>
									<div class="weui-wepay-flow-auto__line weui-wepay-flow-auto__line_on"></div>
									<div class="weui-wepay-flow__intro-right">李四 同学上课记录</div>
								</div>
								<div class="weui-wepay-flow-auto__li">
									<div class="weui-wepay-flow-auto__state weui-wepay-flow-auto__state_on"></div>
									<div class="weui-wepay-flow-auto__line weui-wepay-flow-auto__line_on"></div>
									<p class="weui-wepay-flow-auto__title">张老师</p>
									<p class="weui-wepay-flow-auto__info">上课时间：123456</p>
									<p class="weui-wepay-flow-auto__info">备注说明：无</p>
								</div>
								<div class="weui-wepay-flow-auto__li">
									<div class="weui-wepay-flow-auto__state weui-wepay-flow-auto__state_on"></div>
									<p class="weui-wepay-flow-auto__title">张老师</p>
									<p class="weui-wepay-flow-auto__info">上课时间：123456</p>
									<p class="weui-wepay-flow-auto__info">备注说明：无</p>
								</div>
							</div>
						</div -->					
					</div>
					<div id="editDivStudent" style="display:none;"></div>

				</div>
				<div class="weui-tab__content">
				
					<!-- div class="page__hd">
						<h1 class="page__title">非住宅</h1>
						<p class="page__desc"></p>
					</div -->
					<div id="tidLog" style="display:none; background-color:#FFF;">
					
					</div>
					<div id="addDivStudent" style="display:none;"></div>
					<div class="weui-cells" id="myInfor">
						<div class="weui-cell">
							<div class="weui-cell__hd" style="position: relative;margin-right: 10px;">
								<img src="images/icon_tabbar.png" style="width: 50px;display: block">
							</div>
							<div class="weui-cell__bd">
								<p><?=$t['tidName']?> <small style="color:#888888">钢琴</small></p>
								<p style="font-size: 13px;color: #888888;"></p>
							</div>
						</div>
						<div class="weui-cell">
							<div class="weui-cell__bd">
								学生人数
							</div>
							<div class="weui-cell__ft"><?=teacherBindStudentNum($t['id'])?>人</div>
						</div>			
						<div class="weui-cell weui-cell_access lookTidLog" data-type="0">
							<div class="weui-cell__bd">
								上课次数
							</div>
							<div class="weui-cell__ft"><?=shangKeNum($t['id'])?>次</div>
						</div>			
						<div class="weui-cell  weui-cell_access lookTidLog" data-type="1">
							<div class="weui-cell__bd">
								充值课时
							</div>
							<div class="weui-cell__ft"><?=chongZhiNum($t['id'])?>节</div>
						</div>			
						<div class="weui-cell">
							<div class="weui-cell__bd">
								注册时间
							</div>
							<div class="weui-cell__ft"><?=date("Y-m-d H:i:s",$t['newstime'])?></div>
						</div>			
					</div>					
					<div class="weui-cells addStudent">
						<div class="weui-cell weui-cell_access">
							<div class="weui-cell__bd">
								添加学生
							</div>
							<div class="weui-cell__ft"></div>
						</div>			
					</div>					
				</div>
				<?php require($footer);?>
			</div>
			<div class="weui-tabbar">
				<a href="javascript:;" class="weui-tabbar__item"> <img src="images/icon_tabbar.png" alt="" class="weui-tabbar__icon">
					<p class="weui-tabbar__label">首页</p>
				</a>
				<a href="javascript:;" class="weui-tabbar__item"> <img src="images/icon_tabbar.png" alt="" class="weui-tabbar__icon">
					<p class="weui-tabbar__label">我的</p>
				</a>
			</div>
		</div>
	</div>
</div>

<div id="studentForm" style="display:none;">
	<input type="hidden" name="enews" value="addStudent">
	<div class="weui-cells weui-cells_form">
		<div class="weui-cell">
			<div class="weui-cell__hd"><label for="" class="weui-label">学生姓名</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" value="" name="uidName" type="text">
			</div>
		</div>
	</div>
	<div class="weui-cells weui-cells_form">
		<div class="weui-cell weui-cell_select weui-cell_select-after">
			<div class="weui-cell__hd">
				<label for="" class="weui-label">上课时间</label>
			</div>
			<div class="weui-cell__bd">
				<select class="weui-select" name="week1">
					<option value="1">周一</option>
					<option value="2">周二</option>
					<option value="3">周三</option>
					<option value="4">周四</option>
					<option value="5">周五</option>
					<option value="6">周六</option>
					<option value="7">周日</option>
				</select>
			</div>
		</div>
		<div class="weui-cell weui-cell_access selectTime" href="javascript:;">
			<div class="weui-cell__bd">
				<p>上课时间</p>
			</div>
			<div class="weui-cell__ft time1">18:00</div>
		</div>
	</div>
	<div class="weui-cells weui-cells_form">
		<div class="weui-cell weui-cell_select weui-cell_select-after">
			<div class="weui-cell__hd">
				<label for="" class="weui-label">上课时间</label>
			</div>
			<div class="weui-cell__bd">
				<select class="weui-select" name="week2">
					<option value="1">周一</option>
					<option value="2">周二</option>
					<option value="3">周三</option>
					<option value="4">周四</option>
					<option value="5">周五</option>
					<option value="6">周六</option>
					<option value="7">周日</option>
					<option value="0" selected>可选</option>
				</select>
			</div>
		</div>
		<div class="weui-cell weui-cell_access selectTime" href="javascript:;">
			<div class="weui-cell__bd">
				<p>上课时间</p>
			</div>
			<div class="weui-cell__ft time2">可选</div>
		</div>		
	</div>
	<div class="weui-btn-area">
		<a class="weui-btn weui-btn_primary" href="javascript:" id="buttonAddStudent">确定</a>
		<a class="weui-btn weui-btn_default" href="javascript:" id="escAddStudent">返回</a>
	</div>
</div>



<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> 
<script src="/skin/jquery/jquery.min.js"></script> 
<script src="/skin/jquery/ajaxECMS.js"></script> 
<script src="/skin/weui/weui.min.js"></script> 
<script src="../api.php?enews=getJsConfig"></script>
<script>
var uid=0;
var uidName='';
var uidQRUrl='';
var week1='';
var week2='';
var time1='';
var time2='';
var $studentById="#addDivStudent";
var alertDom;
$(function(){
	weui.tab('#tab',{
		defaultIndex: <?=$tab?>,
		onChange: function(index){
			//window.history.pushState(null, null, "?did=<?=$did?>&tab=" + index);
			escStudentHtml();
		}
	});
	//选择学员
	$(".weui-cells").on("click",".uidInfor",function(e){
		e.preventDefault();
		uid=$(this).attr("uid");
		uidName=$(this).attr("uidName");
		uidQRUrl=$(this).attr("uidQRUrl");

		week1=$(this).attr("week1");
		week2=$(this).attr("week2");
		time1=$(this).attr("time1");
		time2=$(this).attr("time2");
		uidActionSheet();
	});
	//隐藏学员上课记录
	$("#uidLog").on("click","#logClose",function(e){
		e.preventDefault();
		uidActionSheet();
		$("#uidLog").hide();
		$("#uidList").show();
	});
	//查看教师上课记录
	$("#myInfor").on("click",".lookTidLog",function(e){
		e.preventDefault();
		var fromData = {enews:'shangKeList',tid:'<?=$t['id']?>',type:$(this).data("type")};
		$.post("ecms.php",fromData,function(result){
			$("#myInfor").hide();
			$("#tidLog").show().html(result);
		});
	});
	//隐藏教师上课记录
	$("#tidLog").on("click","#logClose",function(e){
		e.preventDefault();
		$("#tidLog").hide();
		$("#myInfor").show();
	});
	//上课签到
	$("#addQianDao").click(function(){
		var fromData = {enews:'qianDao',uid:uid,uidName:uidName,title:$("#QDBZ").val(),num:$("#star").val(),isonly:uid + '-<?=$time?>'};
		var AjaxData = AjaxECMS("ecms.php", 'POST',fromData, "json");
		if(AjaxData.errCode == 0)
		{
			weui.toast('成功', 2000);
			$("#uidList").show();
			$("#qianDaoForm").hide();
			uidActionSheet();
		}
		else
		{
			weui.toast(AjaxData.errMsg, 3000);
			
		}

	})
	//取消上课签到
	$("#escQianDao").click(function(){
		$("#uidList").show();
		$("#qianDaoForm").hide();
		uidActionSheet();
	})
	
	//添加学生
	$(".addStudent").click(function(){
		addStudentHtml("#addDivStudent");
	});
	//操作学生-确定
	$(".weui-tab__content").on("click","#buttonAddStudent",function(e){
		var fromData = {enews:$("input[name='enews']").val()};
		fromData['uid']=uid;
		fromData['uidName']=$("input[name='uidName']").val();
		fromData['week1']=$("select[name='week1']").val();
		fromData['week2']=$("select[name='week2']").val();
		fromData['time1']=$(".time1").text();
		fromData['time2']=$(".time2").text();
		var AjaxData = AjaxECMS("ecms.php", 'POST',fromData, "json");
		if(AjaxData.errCode == 0)
		{
			weui.toast('成功', 2000);
			escStudentHtml(fromData['uidName']);
		}
		else
		{
			weui.toast(AjaxData.errMsg, 3000);
		}
	});
	//操作学生-返回
	$(".weui-tab__content").on("click","#escAddStudent",function(e){
		escStudentHtml();
	});
	//选择上课时间
	$(".weui-tab__content").on("click",".selectTime",function(e){
		var that = this;
		// 多列picker
		weui.picker([
			{
				label: '6点',
				value: '06'
			}, {
				label: '7点',
				value: '07'
			}, {
				label: '8点',
				value: '08'
			}, {
				label: '9点',
				value: '09'
			}, {
				label: '10点',
				value: '10'
			}, {
				label: '11点',
				value: '11'
			}, {
				label: '12点',
				value: '12'
			}, {
				label: '13点',
				value: '13'
			}, {
				label: '14点',
				value: '14'
			}, {
				label: '15点',
				value: '15'
			}, {
				label: '16点',
				value: '16'
			}, {
				label: '17点',
				value: '17'
			}, {
				label: '18点',
				value: '18'
			}, {
				label: '19点',
				value: '19'
			}, {
				label: '20点',
				value: '20'
			}, {
				label: '21点',
				value: '21'
			}, {
				label: '22点',
				value: '22'
			}
		], [
			{
				label: '0分',
				value: '00'
			}, {
				label: '5分',
				value: '05'
			}, {
				label: '10分',
				value: '10'
			}, {
				label: '15分',
				value: '15'
			}, {
				label: '20分',
				value: '20'
			}, {
				label: '25分',
				value: '25'
			}, {
				label: '30分',
				value: '30'
			}, {
				label: '35分',
				value: '35'
			}, {
				label: '40分',
				value: '40'
			}, {
				label: '45分',
				value: '45'
			}, {
				label: '50分',
				value: '50'
			}, {
				label: '55分',
				value: '55'
			}, {
				label: '60分',
				value: '60'
			}
		], {
			defaultValue: ['18', '00'],
			onChange: function (result) {
				console.log(result);
			},
			onConfirm: function (result) {
				console.log(result);
				console.log(result[0]['label']);
				console.log(result[0]['value']);
				console.log(result[1]['label']);
				console.log(result[1]['value']);
				$(that).find(".weui-cell__ft").html(result[0]['value']+':'+result[1]['value']);
			},
			id: 'multiPickerBtn'
		});
	})
	//$("#FaPiaoChongZhiType").change(function(){})
})
wx.ready(function(){
});

//操作学生信息
function uidActionSheet(){
	console.info('resActionSheet');
	weui.actionSheet([
		{
			label: uidName
		},{
			label: '<img id="QRIMG" class="weui-btn_plain-primary" src="'+uidQRUrl+'" width="100" style="padding:0; margin:0;"><small style="display:block; color:#C7C7C7">绑定二维码</small>'
		},{
			label: '上课签到',
			onClick: function () {
				$("#uidList").hide();
				$("#uidLog").hide();
				$("#qianDaoForm input[name='uidName']").val(uidName);
				$("#qianDaoForm").show();

				//showDialog(1);
				console.log('添加上课记录');
			}
		}, {
			label: '上课记录',
			onClick: function () {
				$("#uidList").hide();
				$("#uidLog").show();
				console.log('添加课时');
				var fromData = {enews:'shangKeList',uid:uid,uidName:uidName};
				$.post("ecms.php",fromData,function(result){
					$("#uidLog").html(result);
				});
			}
		}, {
			label: '充值记录',
			onClick: function () {
				$("#uidList").hide();
				$("#uidLog").show();
				console.log('添加课时');
				var fromData = {enews:'shangKeList',uid:uid,uidName:uidName,type:1};
				$.post("ecms.php",fromData,function(result){
					$("#uidLog").html(result);
				});
			}
		}, {
			label: '充值课时',
			onClick: function () {
				showDialog(2);
				console.log('充值课时');
			}
		}, {
			label: '编辑学生',
			onClick: function () {
				addStudentHtml("#editDivStudent");
				console.log('编辑学生');
			}
		}, {
			label: '删除学员',
			onClick: function () {
				showDialog(0);
				console.log('删除学员');
			}
		}
	], [
		{
			label: '取消',
			onClick: function () {
				console.log('取消');
			}
		}
	], {
		className: 'uidActionSheet',
		isAndroid:false
	});	
}
function showDialog(Type){
	var sheet = 0; //为0时弹出ActionSheet
	var title = '删除学员';
	var enews = 'deleteStudent';
	var fromData = {enews:enews,uid:uid};
	var content = '请确认是否真的要删除学员？';
	if(Type==2)
	{
		enews = 'chongZhiKeShi';
		title = '充值课时';
		content = '<input class="weui-prompt-input" id="KSnum" type="tel" placeholder="增加课时数量" value=""><br><input class="weui-prompt-input" id="KSBZ" type="text" placeholder="请输入备注说明" value="">';
		fromData["num"] = $("#num").val();
		fromData["isonly"] = uid + '-<?=$time?>';
	}
	else
	{
	}
	fromData["enews"] = enews;
	
	alertDom = weui.dialog({
		title: title,
		content: content,
		className: 'custom-classname',
		buttons: [{
			label: '取消',
			type: 'default',
			onClick: function () { if(sheet == 0){uidActionSheet();} }
		}, {
			label: '确定',
			type: 'primary',
			onClick: function () {
				if(Type==2)
				{
					fromData["uidName"] = uidName;
					fromData["num"] = $("#KSnum").val();
					fromData["title"] = $("#KSBZ").val();
				}
				else
				{
					fromData["newtime"] = "<?=date("Y-m-d H:i:s")?>";
					fromData["title"] = $("#QDBZ").val();
					fromData["uidName"] = uidName;
				}
				var AjaxData = AjaxECMS("ecms.php", 'POST',fromData, "json");
				if(Type==0)
				{
					$("#uidInfor_"+uid).hide();
				}
				if(Type==0&&AjaxData.errCode == 0)
				{
					weui.toast('操作成功', 3000);
				}
				else if(AjaxData.errCode == 0)
				{
					weui.toast('操作成功', 3000);
					uidActionSheet();
				}
				else
				{
					alert(AjaxData.errMsg);
					return false;
				}
			}
		}]
	});	
}
function addStudentHtml(byId){
	$studentById = byId;
	var $studentForm = $("#studentForm").html();
	$("#studentForm").empty();
	$(byId).html($studentForm).show();
	
	if(byId == "#addDivStudent") //添加
	{
		$("input[name='enews']").val("addStudent")
		$("input[name='uidName']").val("");
		$("#myInfor").hide();
		$(".addStudent").hide();
	}
	else
	{
		if(time1)
		{
			$(".time1").text(time1);
			$("select[name='week1']").find("option").eq(week1-1).attr("selected","selected")
		}
		if(time2)
		{
			$(".time2").text(time2);
			$("select[name='week2']").find("option").eq(week2-1).attr("selected","selected")
		}
		$("input[name='enews']").val("editStudent")
		$("input[name='uidName']").val(uidName);
		$("#uidList").hide();
	}
	console.log(uidName);
}
function escStudentHtml(editUidName){
	var $studentForm = $($studentById).html();
	if($studentForm == ""||$studentForm == undefined) return;
	
	$($studentById).empty().hide();
	
	$("#studentForm").html($studentForm);
	$("input[name='uidName']").val("");
	$("input[name='enews']").val("addStudent")
	if($studentById == "#addDivStudent") //添加
	{
		$("#myInfor").show();
		$(".addStudent").show();
	}
	else
	{
		if(editUidName)
		{
			console.log('uidName:' + uidName);
			uidName=editUidName;
			console.log('uidName:' + uidName);
			$("#uidInfor_"+uid).attr("uidName",editUidName).find(".weui-cell__hd p").text(editUidName);
			
		}
		$("#uidList").show();
		
	}
}
function addButtonStudent(){
	var fromData = {enews:$("input[name='enews']").val()};
	fromData['uidName']=$("input[name='uidName']").val();
	fromData['week1']=$("select[name='week1']").val();
	fromData['week2']=$("select[name='week2']").val();
	fromData['time1']=$(".time1").text();
	fromData['time2']=$(".time2").text();
	var AjaxData = AjaxECMS("ecms.php", 'POST',fromData, "json");
	if(AjaxData.errCode == 0)
	{
		weui.toast('成功', 2000);
		escStudentHtml();
	}
	else
	{
		weui.toast(AjaxData.errMsg, 3000);
	}
}
</script>
</body>
</html>
